package web

import (
	"ksd-social-api/commons/base/controller"
	"ksd-social-api/modules/resume/model/context"
	"ksd-social-api/modules/resume/service"
)

type ResumeController struct {
	controller.BaseController
}

var resumeService = service.ResumeService{}

/**
 * @author feige
 * @date 2023-10-08
 * @desc 查询个人简历服务
 */
func (web *ResumeController) FindResumeByUserId() {
	resumeVos := resumeService.FindResumeByUserId(web.GetUserId(), web.GetSystemId())
	web.Ok(resumeVos)
}

/**
 * @author feige
 * @date 2023-10-08
 * @desc 查询个人简历服务
 */
func (web *ResumeController) SaveUpdateResume() {
	resumeContext := context.ResumeContext{}
	// 2: 开始绑定参数
	web.BindJSON(&resumeContext)
	resumeContext.SystemId = web.GetSystemId()
	resumeContext.SystemName = web.GetSystemName()
	resumeContext.UserId = web.GetUserId()
	resumeContext.Nickname = web.GetUserNickname()
	// 3：执行查询返回
	resumeVo, err := resumeService.SaveUpdateResume(&resumeContext)
	if err != nil {
		web.FailCodeMsg(788, err.Error())
	} else {
		web.Ok(resumeVo)
	}
}

/**
 * @author feige
 * @date 2023-10-08
 */
func (web *ResumeController) GetResumeId() {
	resumeId, _ := web.ParseParamUint64("resumeId")
	pvo, _ := resumeService.GetResumeId(resumeId, web.GetSystemId())
	web.Ok(pvo)
}

/**
 * @author feige
 * @date 2023-10-08
 */
func (web *ResumeController) GetResumeNewFile() {
	resumeId, _ := web.ParseParamUint64("resumeId")
	pvo, err := resumeService.GetResumeFile(resumeId, web.GetUserId(), web.GetSystemId())
	if err != nil {
		web.FailCodeMsg(702, "尚未支付")
		return
	}
	web.Ok(pvo)
}

/**
 * @desc 更新状态
 * @author feige
 * @date 2023-11-14
 * @version 1.0
 */
func (web *ResumeController) UpdateStatus() {
	resumeDetailContext := context.ResumeDetailContext{}
	// 2: 开始绑定参数
	web.BindJSON(&resumeDetailContext)
	resumeDetailContext.SystemId = web.GetSystemId()
	// 3：执行查询返回
	web.Ok(resumeService.UpdateStatus(&resumeDetailContext))
}

/**
 * @desc 更新文件
 * @author feige
 * @date 2023-11-14
 * @version 1.0
 */
func (web *ResumeController) UpdateResumeNewFile() {
	resumeDetailContext := context.ResumeDetailContext{}
	// 2: 开始绑定参数
	web.BindJSON(&resumeDetailContext)
	resumeDetailContext.SystemId = web.GetSystemId()
	// 3：执行查询返回
	web.Ok(resumeService.UpdateResumeNewFile(&resumeDetailContext))
}
